Mechanism for processing speculative LL and SC instructions in a pipelined processor

ABSTRACT

A processor includes a first circuit and a second circuit. The first circuit is configured to provide a first indication of whether or not at least one reservation is valid in the processor. A reservation is established responsive to processing a load-linked instruction, which is a load instruction that is architecturally defined to establish the reservation. A valid reservation is indicative that one or more bytes indicated by the target address of the load-linked instruction have not been updated since the reservation was established. The second circuit is coupled to receive the first indication. Responsive to the first indication indicating no valid reservation, the first circuit is configured to select a speculative load-linked instruction for issued. The second circuit is configured not to select the speculative load-linked instruction for issue responsive to the first indication indicating the at least one valid reservation. A method is also contemplated.

PRIORITY INFORMATION

This application is a continuation of and claims priority to U.S. patentapplication having an application Ser. No. 10/068,286; filed Feb. 06,2002, which application claims benefit of priority to Provisional PatentApplication Ser. No. 60/334,394, filed Nov. 30, 2001, and in which bothare hereby incorporated by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention is related to the field of processors and, moreparticularly, to multiprocessor synchronization mechanisms inprocessors.

2. Description of the Related Art

Processors designed for use in multiprocessing systems typically supportsome sort of mechanism for synchronizing processes executing on thevarious processors. For example, certain sections of code may bedesignated as “critical sections”. Critical sections may updatevariables shared by the processes, read or write files, etc. Typically,the processes are synchronized such that at most one process at anygiven time is executing the critical section. As another example, theprocesses may share certain data areas in memory. Access to the shareddata areas may be controlled in a similar fashion, synchronizing suchthat at most one process has access (or perhaps at most one process haswrite access, with other processes possibly having read-only access) tothe shared data area at any given time.

Support for synchronization has been provided by processors in the formof an atomic read-modify-write of a memory location. The atomicread-modify-write can be used to implement various synchronizationprimitives such as test and set, exchange, fetch and add, compare andswap, etc. Synchronization may be managed by using atomicread-modify-writes to designated memory locations to communicate whetheror not a critical section or shared data area is available, to indicatewhich process currently has access to the critical section or shareddata area, etc.

Some processors may support atomic read-modify-writes using a lockmechanism. With a lock mechanism, when a processor accesses a memorylocation, other access to that memory location is prevented until theprocessor releases the lock. The atomicity of the read-modify-writeoperation to the memory location is guaranteed by preventing otherprocessors from accessing that memory location. Lock mechanisms may beproblematic in practice. For example, if the lock is implemented bylocking a resource for accessing memory (e.g. a shared bus), deadlockmay result (especially in coherent systems). Lock mechanisms for largersystems (e.g. multiple levels of interconnect between processors) may beproblematic to implement.

Another approach for providing an atomic read-modify-write mechanism isthe load-linked/store conditional mechanism. In this mechanism, twotypes of instructions are provided: the load-linked and the storeconditional. Generally, a load-linked instruction and a storeconditional instruction to the same address are used in pairs. Theload-linked instructions operate similar to typical load instructions,but also cause the processor to monitor the target address of the loadinstruction (the address of the data accessed by the load). The storeconditional instruction conditionally stores to the target address basedon whether or not the target address is updated by anotherprocessor/device between the load-linked instruction and the storeconditional instruction. Other conditions may cause the store not tooccur as well. The store conditional may provide an indication ofwhether or not the store was performed, which may be tested bysubsequent instructions to either branch back to the load-linkedinstruction to attempt the read-modify-write operation again (if thestore was not successfully performed) or to continue processing (if thestore was successfully performed). With the load-linked/storeconditional mechanism, other processors may access the memory locationfor which the atomic read-modify-write is being attempted. If amodification occurs, the load-linked/store conditional sequence isrepeated. When the store conditional completes successfully, an atomicread-modify-write of the location has been performed.

Since the processor resources for monitoring the target addresses ofload-linked instructions is limited, speculative execution ofload-linked instructions may be problematic. If a speculativeload-linked instruction causes the processor to begin monitoring itstarget address and the speculative load-linked instruction is latercanceled (e.g. due to branch misprediction or exception), a subsequentstore conditional instruction may incorrectly complete successfullybased on the target address of the speculative load-linked instruction.Similarly, a speculative load-linked instruction may cause the processorto cease monitoring the target address of a previous (non-speculative)load-linked instruction. The store conditional corresponding to theprevious load-linked instruction may complete unsuccessfully in thiscase.

SUMMARY OF THE INVENTION

A processor is contemplated, comprising a first circuit and a secondcircuit. The first circuit is configured to provide a first indicationof whether or not at least one reservation is valid in the processor. Areservation is established responsive to processing a load-linkedinstruction, which is a load instruction that is architecturally definedto establish the reservation. A valid reservation is indicative that oneor more bytes indicated by the target address of the load-linkedinstruction have not been updated since the reservation was established.The second circuit is coupled to receive the first indication.Responsive to the first indication indicating no valid reservation, thefirst circuit is configured to select a speculative load-linkedinstruction for issued. The second circuit is configured not to selectthe speculative load-linked instruction for issue responsive to thefirst indication indicating the at least one valid reservation.

A method is also contemplated. Whether or not at least one reservationis valid in a processor is determined. Responsive to no validreservation, a speculative load-linked instruction is selected forissue. Responsive to at least one valid reservation, the speculativeload-linked instruction is not selected for issue.

BRIEF DESCRIPTION OF THE DRAWINGS

The following detailed description makes reference to the accompanyingdrawings, which are now briefly described.

FIG. 1 is a block diagram of one embodiment of a processor.

FIG. 2 is a block diagram of one embodiment of issue logic for theprocessor shown in FIG. 1.

FIG. 3 is a block diagram of one embodiment of a load/store pipeline forthe processor shown in FIG. 1.

FIG. 4 is a flowchart illustrating operation of one embodiment of issuelogic in the processor shown in FIG. 1 for issuing load-linked (LL)instructions.

FIG. 5 is a flowchart illustrating operation of one embodiment of a LLcontrol circuit shown in FIG. 3.

FIG. 6 is a block diagram of one embodiment of a carrier medium.

While the invention is susceptible to various modifications andalternative forms, specific embodiments thereof are shown by way ofexample in the drawings and will herein be described in detail. Itshould be understood, however, that the drawings and detaileddescription thereto are not intended to limit the invention to theparticular form disclosed, but on the contrary, the intention is tocover all modifications, equivalents and alternatives falling within thespirit and scope of the present invention as defined by the appendedclaims.

DETAILED DESCRIPTION OF EMBODIMENTS

Processor Overview

Turning now to FIG. 1, a block diagram of one embodiment of a processor10 is shown. Other embodiments are possible and contemplated. In theembodiment of FIG. 1, the processor 10 includes an instruction cache 12,a fetch/decode/issue unit 14, a branch prediction unit 16, a set ofinteger execution units 22A-22B, a set of floating point execution units24A-24B, a set of load/store execution units 26A-26B, a register file28, a data cache 30, and a bus interface unit 32. The instruction cache12 is coupled to the bus interface unit 32, and is coupled to receive afetch address from, and provide corresponding instructions to, thefetch/decode/issue unit 14. The fetch/decode/issue unit 14 is furthercoupled to the branch prediction unit 16 and the execution units22A-22B, 24A-24B, and 26A-26B. Specifically, the fetch/decode/issue unit14 is coupled to provide a branch address to the branch prediction unit16 and to receive a prediction and/or a target address from the branchprediction unit 16. The fetch/decode/issue unit 14 is coupled to provideinstructions for execution to the execution units 22A-22B, 24A-24B, and26A-26B. Additionally, the fetch/issue/decode unit 14 is coupled toreceive a redirect indication from the integer unit 22A and exceptionindications from the execution units 22A-22B, 24A-24B, and 26A-26B. Thefetch/issue/decode unit 14 is coupled to provide a replay indication tothe execution units 22A-22B, 24A-24B, and 26A-26B. The execution units22A-22B, 24A-24B, and 26A-26B are generally coupled to the register file28 and the data cache 30, and the data cache 30 is coupled to the businterface unit 32.

Generally speaking, the fetch/decode/issue unit 14 is configured togenerate fetch addresses for the instruction cache 12 and to receivecorresponding instructions therefrom. The fetch/decode/issue unit 14uses branch prediction information to generate the fetch addresses, toallow for speculative fetching of instructions prior to execution of thecorresponding branch instructions. Specifically, in one embodiment, thebranch prediction unit 16 include an array of branch predictors indexedby the branch address (e.g. the typical two bit counters which areincremented when the corresponding branch is taken, saturating at 11 inbinary, and decremented when the corresponding branch is not taken,saturating at 00 in binary, with the most significant bit indicatingtaken or not taken). While any size and configuration may be used, oneimplementation of the branch predictors 16 may be 4 k entries in adirect-mapped configuration. Additionally, in one embodiment, the branchprediction unit 16 may include a branch target buffer comprising anarray of branch target addresses. The target addresses may be previouslygenerated target addresses of any type of branch, or just those ofindirect branches. Again, while any configuration may be used, oneimplementation may provide 64 entries in the branch target buffer. Stillfurther, an embodiment may include a return stack used to store linkaddresses of branch instructions which update a link resource (“branchand link” instructions). The fetch/decode/issue unit 14 may provide linkaddresses when branch instructions which update the link register arefetched for pushing on the return stack, and the return stack mayprovide the address from the top entry of the return stack as apredicted return address. While any configuration may be used, oneimplementation may provide 8 entries in the return stack.

The fetch/decode/issue unit 14 decodes the fetched instructions andqueues them in one or more issue queues for issue to the appropriateexecution units. The instructions may be speculatively issued to theappropriate execution units, again prior to execution/resolution of thebranch instructions which cause the instructions to be speculative. Insome embodiments, out of order execution may be employed (e.g.instructions may be issued in a different order than the program order).In other embodiments, in order execution may be used. However, somespeculative issue/execution may still occur between the time that abranch instruction is issued and its result is generated from theexecution unit which executes that branch instruction (e.g. theexecution unit may have more than one pipeline stage).

The integer execution units 22A-22B are generally capable of handlinginteger arithmetic/logic operations, shifts, rotates, etc. At least theinteger execution unit 22A is configured to execute branch instructions,and in some embodiments both of the integer execution units 22A-22B mayhandle branch instructions. In one implementation, only the executionunit 22B executes integer multiply and divide instructions although bothmay handle such instructions in other embodiments. The floating pointexecution units 24A-24B similarly execute the floating pointinstructions. The integer and floating point execution units 22A-22B and24A-24B may read and write operands to and from the register file 28 inthe illustrated embodiment, which may include both integer and floatingpoint registers. The load/store units 26A-26B may generate load/storeaddresses in response to load/store instructions and perform cacheaccesses to read and write memory locations through the data cache 30(and through the bus interface unit 32, as needed), transferring data toand from the registers in the register file 28 as well.

The instruction cache 12 may have any suitable configuration and size,including direct mapped, fully associative, and set associativeconfigurations. Similarly, the data cache 30 may have any suitableconfiguration and size, including any of the above mentionedconfigurations. In one implementation, each of the instruction cache 12and the data cache 30 may be 4 way set associative, 32 kilobyte (kb)caches including 32 byte cache lines. Both the instruction cache 12 andthe data cache 30 are coupled to the bus interface unit 32 fortransferring instructions and data into and out of the caches inresponse to misses, flushes, coherency activity on the bus, etc.

In one implementation, the processor 10 is designed to the MIPSinstruction set architecture (including the MIPS-3D and MIPS MDMXapplication specific extensions). The MIPS instruction set may be usedbelow as a specific example of certain instructions. However, otherembodiments may implement the IA-32 or IA-64 instruction setarchitectures developed by Intel Corp., the PowerPC instruction setarchitecture, the Alpha instruction set architecture, the ARMinstruction set architecture, or any other instruction set architecture.

It is noted that, while FIG. 1 illustrates two integer execution units,two floating point execution units, and two load/store units, otherembodiments may employ any number of each type of unit, and the numberof one type may differ from the number of another type.

The redirect, replay, and exception indications may be used in themanagement of speculative instruction execution and dependencymanagement, as described in more detail below. Generally, the redirectindication may indicate whether or not a predicted branch was predictedcorrectly. Each of execution units 22A-22B, 24A-24B, and 26A-26B mayindicate whether or not an instruction experiences an exception usingthe corresponding exception indication. The replay indication may beprovided by the fetch/decode/issue unit 14 if a replay condition isdetected for an instruction.

Speculative Load-Linked/Store Conditional Handling

The processor 10 may be configured to speculatively issueload-linked/store conditional instructions. In one embodiment, theprocessor 10 employs one or more storage devices for storing targetaddresses of previously processed load-linked instructions as well ascorresponding reservation indications indicative of whether or not avalid reservation is being maintained by the processor 10 for thecorresponding target address. The reservation indications may be in oneof at least two states: a first state indicating that the reservation isvalid and a second state indicating that the reservation is invalid. Ifthe reservation indication in each storage device is in the second state(no valid reservations), a speculative load-linked instruction may beissued. If at least one reservation indication is in the first state(valid reservation), then a speculative load-linked instruction is notissued. In one embodiment, if a valid reservation is being maintained bythe processor 10, a speculative load-linked instruction is not issueduntil the instructions prior to that load-linked instruction havegraduated. Additionally, in one embodiment having pipelined processingof load instructions, if a load-linked instruction is in the pipeline, aspeculative load-linked instruction is not issued.

Accordingly, the processor 10 may speculatively issue the firstload-linked instruction encountered when no valid reservations are beingmaintained. If the first load-linked instruction misses the data cache30, the miss processing may begin speculatively for the firstload-linked instruction in a sequence of one or more load-linkedinstructions. In some code sequences, the latency of the firstload-linked instruction may be important to performance of the codesequence.

During processing of the speculative load-linked instruction, areservation may be established in the storage devices. Since theload-linked instruction is speculative, it may not complete execution(e.g. it may be canceled before the graduation stage, at which theload-linked instruction is committed to architected state). For example,if the load-linked instruction is subsequent to a mispredicted branchinstruction, the redirect caused when the branch misprediction isdetected may cause the load-linked instruction not to complete.Additionally, in one embodiment, the processor 10 supports the replay ofinstructions if dependencies are not resolved for a given instruction bythe time that the instruction reaches the register file read stage(instead of stalling the pipeline and waiting for the operands). If aload-linked instruction is replayed (or a preceding instruction isreplayed), the load-linked instruction does not complete execution. Ifthe load-linked instruction experiences an exception (or a precedinginstruction experiences an exception), the load-linked instruction doesnot complete execution.

If a load-linked instruction does not complete execution, the processor10 may invalidate each of the valid reservations. Since speculativeload-linked instructions are not issued if there are valid reservations,the reservations being invalidated may generally be speculativereservations. In this manner, incorrect successfully completions ofstore conditional instructions may be avoided.

In one embodiment, the store conditional instruction may also bespeculatively issued. The store conditional instruction may be processedto the graduation stage without updating the data cache 30. If the storeconditional is ready to graduate, the reservations may be checked to seeif the store conditional is successful. In one embodiment, the processor10 recycles the store conditional instruction from the graduation stageback into the load/store pipeline again. During the second pass, thestore may check the reservations and update the cache. The load/storepipeline may signal the success or failure to the issue logic, which mayissue a pseudo-op to update the destination register of the conditionalstore with an indication of the success/failure of the conditionalstore.

For the discussion of one embodiment of the processor 10 below (withregard to FIGS. 2-5), an example using the MIPS instruction set (and theLL and SC instructions as examples of the load-linked and storeconditional instructions, respectively) will be used. However, otherembodiments may implement other instruction sets, including otherexamples of a load-linked and store conditional instruction. The detailsof the instructions may vary. For example, the store conditionalinstructions in the PowerPC instruction set are the conditional storeword (stwcx.) or conditional store doubleword (stdcx.) instructions. Thesuccess or failure of the stwcx. and stdcx. instructions is reported ina condition code register. In contrast, the SC instruction in the MIPSinstruction set reports the success or failure by writing a one or azero (respectively) to the register sourcing the store data for the SCinstruction.

Generally, as used herein, a “load-linked” instruction is a loadinstruction which is architecturally defined (by the processorarchitecture implemented by the processor 10) to establish a reservationfor the target address of the load-linked instruction. For example, inthe MIPS instruction set, an example of a load-linked instruction may bethe LL instruction. Other instruction sets may implement examples ofload-linked instructions. For example, the PowerPC instruction setincludes a load word and reserve (lwarx) instruction and a loaddoubleword and reserve (ldarx) instruction, which may be examples ofload-linked instructions. Any load instruction which establishes areservation for the target address of that load instruction may be aload-linked instruction. As used herein, a “store conditional”instruction is a store instruction which is architecturally defined toperform the store conditionally dependent on a valid reservationexisting in the processor. Specifically, the store is performed (thememory location specified by the target address of the store is updated)if a valid reservation exists and the store is not performed (the memorylocation specified by the target address of the store is not updated) ifa valid reservation does not exist. As mentioned above, the SCinstruction of the MIPS instruction set and the conditional store word(stcwx.) and a conditional store doubleword (stcdx.) instructions of thePowerPC instruction may be examples of a store conditional instruction.Any store instruction which is conditional on a valid reservation may bestore conditional instruction. In some embodiments, the storeconditional instruction may report the success or failure of the store(e.g. by updating the source register for the store conditionalinstruction, a condition code register, or other mechanisms).

As used herein, if a processor has a “reservation” for a target address,the processor is monitoring for updates to the target address, separatefrom monitoring the data cache 30 for coherency reasons. A reservationis established in response to a load-linked instruction. A validreservation is a reservation which: (i) has been established; (ii) hasnot been invalidated due to an update to the target address by anotherprocessor or device. In other words, a valid reservation is indicativethat one or more bytes indicated by the target address of theload-linked instruction have not been updated since the reservation wasestablished. A valid reservation may also be invalidated due to thesuccess of a corresponding store conditional instruction. Other causesmay invalidate a reservation, in some embodiments. For example, if thecache line including the target address is evicted from the data cache,the reservation may be invalidated. If an exception is experienced, thereservation may be invalidated. In various embodiments, the granularityon which the reservation is maintained may be varied. For example, thegranularity may be the size of the data accessed (e.g. a word), or maybe a larger granularity (e.g. a cache block containing the word). If alarger granularity is used, updates to the target address or to otheraddresses within the granularity may cause the reservation to beinvalidated.

Turning next to FIGS. 2-5, a specific example of the processor 10implementing the MIPS instruction set (including the LL and SCinstructions) will be described. For this embodiment, several registersare used to maintain multiple reservations concurrently (e.g. 4 in oneexample). In one particular embodiment, the data cache 30 comprisesmultiple banks and a reservation is maintained for each bank of the datacache 30. Other embodiments may maintain as few as one valid reservationor as many reservations as desired. Any type of storage device (e.g.memory such as random access memory (RAM), a set of flops, latches, etc.may be used). Additionally, the reservation indication in each storagedevice is illustrated as a bit in the example below (the LL bit). Thebit being set indicates a valid reservation (e.g. the first statementioned above) and the bit being clear indicates an invalidreservation (e.g. the second state mentioned above). Other embodimentsmay reverse the meaning of the set and clear states of the bit or mayuse other indications, as desired.

Turning now to FIG. 2, a block diagram of one embodiment of a portion ofthe fetch/decode/issue unit 14 is shown. Other embodiments are possibleand contemplated. In the embodiment of FIG. 2, the fetch/decode/issueunit 14 includes an issue queue 40, and an issue control circuit 42. Theissue queue 40 is coupled to receive instructions from the decodecircuitry (not shown), and is configured to provide instructions to theinteger execution units 22A-22B, the floating point execution units24A-24B, and the load/store units 26A-26B. The issue queue 40 is coupledto the issue control circuit 42, which is further coupled to receive theredirect indication and the exception indications shown in FIG. 1, andto provide the replay indication shown in FIG. 1. Additionally, theissue control circuit 42 is coupled to receive an LL_set indication andan SC_stat indication from the load/store pipeline (an embodiment ofwhich is illustrated in FIG. 3) and to provide a Clr_LL indication tothe load/store pipeline.

The issue queue 40 receives decoded instructions from the decode logicand queues the instructions at least until they are issued. In oneembodiment, the issue queue 40 queues the instructions until they aregraduated. The issue queue comprises a plurality of entries for storinginstructions and related information. Certain fields of information inan exemplary entry 48 are shown in FIG. 2. The type of instruction isstored in a type field of the entry. The type may be the opcode of theinstruction (possibly decoded by the decode logic), or may be a fieldwhich indicates instruction types used by the issue control circuit 42for selecting instructions for issue. The destination register number isstored in a dest. reg. field. Similarly, the source register numbers maybe stored in the src1 reg. field, the src2 reg. field, and the src3 reg.field. Most instructions may have at most two source register operandsindicated by the register numbers in the src1 and src2 reg. fields.However, the floating point multiply-add instruction may have threesource operands (e.g. src1 and src2 may be the multiplicands and src3may be the add operand).

Finally, a pipe state field is shown. The pipe state stored in the pipestate field may track the pipe stage that the corresponding instructionis in. The pipe state may be represented in any fashion. For example,the pipe state may be a bit vector with a bit corresponding to eachpipeline stage. The first bit may be set in response to the issuance ofthe instruction, and the set bit may be propagated down the bit vectoron a cycle-by-cycle basis as the instruction progresses through thepipeline stages. Alternatively, the pipe state may be a counter which isincremented as the instruction progresses from pipeline stage topipeline stage. In one embodiment, the pipelines in the integer,floating point, and load/store execution units do not stall (instructionreplay may be used where an instruction may otherwise stall in thepipeline). Accordingly, the pipe state may change to the next stage eachclock cycle until the instruction is either canceled or graduates.

The pipe state may be used by the issue control circuit 42 to determinewhich pipeline stage a given instruction is in. Thus, the issue controlcircuit 42 may determine when source operands are read for a giveninstruction, when the instruction has reached the replay or graduationstage, etc. Other embodiments may track the pipeline stage for eachinstruction in other fashions as well.

The issue control circuit 42 scans the instructions in the issue queue40 and selects instructions for issue to the integer execution units22A-22B, the floating point execution units 24A-24B, and the load/storeunits 26A-26B. In one embodiment, the issue control circuit 42 mayimplement one or more scoreboards for dependency management, and theselection of instructions may be affected by the scoreboards maintainedby the issue control circuit 42.

If an instruction is selected for issue, the issue control circuit 42may signal the issue queue 40 to output the instruction to the unitselected by the issue control circuit 42 for executing the correspondinginstruction. Load/store instructions are issued to one of the load/storeunits 26A-26B. Integer instructions are issued to one of the integerexecution units 22A-22B. In the present embodiment, certain integerinstructions may be issued to either the load/store units 26A-26B or theinteger execution units 22A-22B (e.g. instructions which may be executedusing the address generation hardware in the load/store pipeline, suchas add instructions). Floating point instructions are issued to thefloating point execution units 24A-24B.

Generally, the issue control circuit 42 attempts to concurrently issueas many instructions as possible, up to the number of pipelines to whichthe issue control circuit 42 issues instructions (e.g. 6 in thisembodiment). In some embodiments, the maximum number of concurrentlyissued instructions may be less than the number of pipelines (e.g. 4 inone embodiment).

The issue control circuit 42 may apply various issue criteria to selectLL and SC instructions for issue. The issue criteria for LL and SCinstructions may include checking scoreboards for dependencies (or otherdependency management mechanisms), resource availability for execution,etc., similar to other instructions. Additionally, the issue criteriafor speculative LL instructions may include whether or not a validreservation is currently maintained by the processor 10. In oneembodiment, the issue control circuit 42 is coupled to receive an LL_setindication indicative of whether or not one or more valid reservationsare maintained (indicated by a corresponding LL bit being set, asmentioned above). If at least one LL bit is set (at least onereservation is valid), then the issue control circuit 42 may not selectthe speculative LL instruction for issue. If all LL bits are clear, thecontrol circuit 42 may select the speculative LL instruction for issue.

The LL_set indication is provided by the load/store pipeline. Theload/store pipeline (an example of which is shown in FIG. 3) may beimplemented in the load/store units 26A-26B, or a combination of theload/store units 26A-26B and data cache 30. There may be more than onepipeline (e.g. one pipeline per load/store unit 26A-26B). Generally, theload/store pipeline includes circuitry to generate the LL_set indicationfrom the LL bits in the reservation registers. In embodiments employingonly one reservation register, the LL_set indication may be the LL bitfrom the reservation register. In one embodiment, the LL_set indicationis a signal asserted to indicate that at least one LL bit is set anddeasserted to indicate that all LL bits are clear. Other embodiments mayuse other indications (e.g. the number of LL bits which are set), ifdesired.

An additional issue criteria for speculative LL instructions forpipelined embodiments is that no LL instructions are in the pipeline(also referred to as “in flight”). If an LL instruction is in thepipeline, it will set an LL bit when it reaches the pipeline stage inwhich the reservation registers are updated (e.g. the cache accessstage, in one embodiment). Thus, this issue criteria may be viewed as anextension of the criteria that a speculative LL instruction is notissued if at least one LL bit is set in the reservation registers. Inone embodiment, the issue control circuit 42 may determine if an LLinstruction is in the pipeline from the pipe state and type fields inthe issue queue 40. Other embodiments may receive information from theload/store pipelines as to whether or not LL instructions are in thepipeline, or use any other mechanism for tracking LL instructions in thepipeline.

As mentioned above, SC instructions may generally be issuespeculatively. Accordingly, for this embodiment, no additional issuecriteria may be applied to SC instructions. In one embodiment, the issueof an SC instruction may cause the issue control circuit 42 to inhibitissue of subsequent load/store instructions until the SC completes(successfully or unsuccessfully). As mentioned above, in oneimplementation the SC instruction passes through the load/store pipelineto the graduation stage, then passes through the load/store pipelineagain as a graduated SC and checks the cache and LL bit to determine ifthe SC completes successfully. The load/store pipeline may transmit anSC_stat indication to indicate the status of the SC instruction. TheSC_stat indication may be a signal (e.g. asserted to indicate successand deasserted to indicate failure) which may be qualified by the issuecontrol circuit 42 detecting a graduated SC instruction in theappropriate pipeline stage (e.g. the cache access stage). For example,the issue control circuit 42 may use the pipe state information toqualify the SC_stat signal. Other embodiments may use multiple signalsfor the SC_stat indication to indicate whether or not status is beingreported in addition to the status itself. Depending on the SC_statindication, the issue control circuit 42 may cause the issuance of oneof two pseudo ops which write the source register of the data for the SCinstruction with a 1 (to indicate success) or a 0 (to indicate failure).Other embodiments may update the register in other fashions.

The issue control circuit 42 receives exception and redirect indicationsfrom the execution units, and detects replay scenarios (e.g. due tounresolved dependencies for instructions in the pipeline). Otherembodiments may have the execution units detect replay scenarios aswell. The issue control circuit 42 may update the pipe state ofinstructions which are cancelled due to the exception, redirect, orreplay. Additionally, the issue control circuit 42 may detect whether ornot an LL instruction is cancelled due to the exception, redirect, orreplay. In the case of the exception or replay, the exception or replaymay be detected for the LL instruction itself, or for a precedinginstruction in program order. The redirect may be for a mispredictedbranch instruction which precedes the LL instruction in program order.In each case, the LL instruction does not complete execution.Accordingly, the LL bit set in response to the LL instruction should becleared. In the present embodiment, the issue control circuit 42transmits a Clr_LL indication to the load/store pipeline to cause thecircuitry managing the reservation registers to clear the LL bits in thereservation register.

While the issue control circuit 42 detects cancelled LL instructions inthis embodiment, other embodiments are contemplated in which theload/store pipeline(s) detect the canceled LL instruction and clear theLL bits. While one issue queue 40 is illustrated in the presentembodiment, other embodiments may use multiple issue queues fordifferent pipelines or different types of instructions. Variousembodiments may employ in order or out of order issue, as desired. Issuemay be to reservation stations for some embodiments of out of orderexecution (either centralized or distributed).

Turning now to FIG. 3, a block diagram of one embodiment of a load/storepipeline 50 is shown. Other embodiments are possible and contemplated.In the embodiment of FIG. 3, the pipeline 50 is coupled to receive aninstruction (or corresponding control information such as whether theinstruction is a load or store, LL or SC, etc.) and operands from theissue stage of the pipeline (in which the issue control circuit 42 readsthe instruction from the issue queue 40 and the operands are read fromthe register file 28). The pipeline 50 may be implemented in one or bothof the load/store units 26A-26B, or a combination of one or both of theload/store units 26A-26B and the data cache 30. In the embodiment ofFIG. 3, the pipeline 50 includes an address generator 52, a translationlookaside buffer 54, an LL control circuit 56, a set of reservationregisters 58A-58D, and an LL_set circuit 60. Various elements in FIG. 3are separated by pipeline storage devices such as storage devices62A-62D shown in FIG. 3 to illustrate the pipeline stages for theillustrated embodiment. The pipeline storage devices may be latches,flops, registers, or any other form of storage, as desired.

The address generator 52 includes hardware (e.g. an adder) to generatethe virtual target address (VA) of the instruction. Generally, theoperands may include one or more address operands to be added to producethe VA. The operands may include register values, a displacement encodedinto the instruction itself, etc. The VA and the instruction areprovided to the next pipeline stage, which includes the TLB 54. The TLB54 caches virtual to physical translations. If the TLB 54 is storing avirtual to physical translation corresponding to the VA, the TLB 54outputs the corresponding physical address (PA). If the TLB 54 is notstoring a virtual to physical translation, then a table walk of theaddress translation tables (stored in memory) is performed to reload atranslation into the TLB 54. In one embodiment, the table walk isperformed in software and an exception is signaled for a load/storeinstruction which misses the TLB 54. In other embodiments, the tablewalk may be performed in hardware.

The PA and instruction are provided to the next pipeline stage, at whichthe cache access occurs. The PA is transmitted to the data cache 30 forlookup. Additionally, the PA and instruction are provided to the LLcontrol circuit 56. If the instruction is an LL instruction, the LLcontrol circuit 56 updates one of the reservation registers 58A-58D withthe PA and sets the LL bit in that register. Particularly, in theillustrated embodiment, one reservation register 58A-58D is assigned toeach bank of the data cache 30 (i.e. the data cache 30 includes 4 banksin the illustrated embodiment). Reservation register 58A is assigned tobank 0, reservation register 58B is assigned to bank 1, etc., as shownin FIG. 3. While 4 banks are used in the present embodiment, eachassigned a different reservation register 58A-58D, other embodiments mayvary the number of banks. For this embodiment, the LL control circuit 56determines the bank accessed by the LL instruction and updates thecorresponding reservation register 58A-58D.

In one embodiment, address bits are used to select which bank isaccessed in the data cache 30. The LL control circuit 56 may use thesame address bits to select which of the reservation registers 58A-58Dto update. In other embodiments, the bank may be determined in differentways. For example, a set associative embodiment of the data cache 30 mayhave different ways in different banks. In such an embodiment, the LLcontrol circuit 56 may receive a way indication from the data cache 30identifying the way that is hit by a given address, and the wayindication may be used to select the reservation register 58A-58D to beupdated.

The LL control circuit 56 may also respond to an SC instruction which ispassing through the pipeline 50 a second time after successfullyreaching the graduation stage. The SC instruction may be reinserted inthe pipeline at any stage (e.g. the issue stage, the address generationstage, the TLB stage, or the cache access stage). If a graduated SCinstruction occurs, the LL control circuit 56 may check the PA of the SCinstruction against the address in the reservation register 58A-58D ofthe bank accessed by the SC instruction, as well as the corresponding LLbit in that reservation register. If the addresses match and the LL bitis set, the SC instruction succeeds. Otherwise, the SC instructionfails. The LL control circuit 56 may generate the SC_stat indicationaccordingly.

The instruction passes from the cache access stage to the next stage(not shown in FIG. 3). The next stage may, in one embodiment, be thestage at which branch redirect and replay is signaled. Other embodimentsmay detect these events at other stages. The load/store pipeline 50 mayinclude zero or more additional stages (not shown) before theinstruction reaches the graduation stage (illustrated by pipelinestorage device 62D in FIG. 3). The graduation stage is the stage atwhich exceptions are reported for an instruction (if any) and, if noexceptions for previous instructions or the instruction prevent it, theinstruction results are committed to architected state (e.g. registersin the register file 28 or, in the case of store instructions, the stageat which the memory update may be committed). The actual update may bedelayed, but may not be canceled after graduation occurs.

Since the reservation registers 58A-58D are updated in response to an LLinstruction prior to the graduation of that instruction, the update isspeculative if the LL instruction is speculative. Accordingly, in theillustrated embodiment, the issue control circuit 42 detects thecancellation of a speculative LL instruction and generates the Clr_LLindication to the LL control circuit 56. If the Clr_LL indication isreceived (e.g. a signal asserted to indicate that the LL bits are to becleared), the LL control circuit 56 clears each of the LL bits in thereservation registers 58A-58D.

The LL control circuit 56 also receives a snoop input from the businterface unit 32 in this embodiment. The snoop input may include theaddress snooped from the bus, as well as the type of transaction or thetype of snoop to perform. If the type of transaction or snoop indicatesthat the address may be updated by the master on the bus (which may beanother processor or any other device in the system with the processor10), and the processor 10 has a valid reservation for the address, thereservation is invalidated (e.g. the LL bit is cleared). Viewed inanother way, any type of transaction or snoop that indicates that theprocessor 10 is allowing another master to take exclusive access to thecache block including the address for which the processor 10 has a validreservation may cause the reservation to be invalidated. For example, awrite transaction or a read to modify transaction may cause thereservation to be invalidated. A snoop that invalidates the cache blockcorresponding to the address may cause the reservation to beinvalidated.

The LL control circuit 56 compares the snoop address to the addresses inthe reservation registers 58A-58D. If a match is detected in one of thereservation registers 58A-58D, the LL control circuit 56 clears the LLbit in that reservation register 58A-58D.

In one embodiment, the eviction of the cache block corresponding to theaddress in one of the reservation registers 58A-58D causes thereservation to be invalidated. Accordingly, the illustrated embodimentincludes an evict input from the data cache 30. The evict input mayinclude a signal indicating that an eviction is occurring (e.g. to storedata corresponding to a cache miss) and the address of the cache blockbeing evicted. The LL control circuit 56 compares the address to theaddresses stored in the reservation registers 58A-58D and, if a match isfound in one of the reservation registers 58A-58D, clears the LL bit inthat reservation register 58A-58D.

The LL_set circuit 60 is configured to generate the LL_set signal forthe issue control circuit 42. In the illustrated embodiment, in whichthe reservation indications are the LL bits and the LL bit being setindicates a valid reservation, the LL_set signal may be the logical ORof the LL bits. Thus, the LL_set signal may be asserted at a logical oneand deasserted at a logical zero. If the opposite definition of assertedand deasserted is used, the LL_set circuit 60 may perform a logical NOR.Various logic circuits may be used dependent on the logical sense of theLL bits and the LL_set signal. Still further, other embodiments may useother reservation indications and LL_set indications, leading to otherlogical circuits. Any Boolean equivalents may also be used.

It is noted that, in other embodiments, a single input may be used forboth evicts and snoops, if desired. It is noted that snoop or evictaddresses may be defined to match the reservation addresses if theaddresses identify the same cache block (e.g. the granularity of thecompare may be the cache block). If snoops are performed on a differentgranularity than the cache block, the snoop granularity may be used forthe snoops. Generally, the least significant bits of the reservationaddress which define an offset within the cache block or snoop block maybe ignored in the comparison.

It is noted that, in the embodiment of processor 10 shown in FIG. 1, twoload/store units 26A-26B are illustrated. In such an embodiment, twoload/store instructions may be processed in parallel. Thus, there may betwo pipelines similar to load/store pipeline 50. The two pipelines mayshare the LL control circuit 56 and reservation registers 58A-58D. Inembodiments including more than two load/store units 26A-26B, additionalload/store pipelines similar to pipeline 50 may be included for eachadditional unit. Other embodiments may include a single pipeline 50 fora single load/store unit.

In the illustrated embodiment, the load/store pipeline 50 includes anaddress generation stage, a TLB stage, a cache access stage, a replaystage, and a graduation stage (which may be one or more stages away fromthe replay stage). Other embodiments may implement a different pipelineor no pipeline at all, as desired. The division of pipeline stages maydiffer. For example, the TLB lookup may be performed in parallel withthe cache access and the TLB stage may be eliminated.

In the illustrated embodiment, multiple reservations are maintained (oneper bank). In other embodiments, as few as one reservation may bemaintained. More reservations may be maintained, as desired.Furthermore, if multiple reservations are maintained, they may notnecessarily be assigned to banks as in the present embodiment.

Turning next to FIG. 4, a flowchart is shown illustrating operation ofone embodiment of the issue control circuit 42 for applying extra issuecriteria to LL instructions. Other embodiments are possible andcontemplated. While the blocks shown in FIG. 4 are illustrated in aparticular order for ease of understanding, other orders may be used.The embodiment illustrated in FIG. 4 may represent the operation ofcircuitry in the issue control circuit 42. Thus, blocks may representparallel operation of the circuitry rather than any particular order.Furthermore, some blocks may be independent of each other and thus mayrepresent independent circuitry that operates in parallel.

If the LL instruction is non-speculative (decision block 70), the LLinstruction may be issued (block 72). If the LL instruction isspeculative, the LL instruction may be issued if the LL_set signal isdeasserted (decision block 74) and no LL instructions are in flight(decision block 76). Otherwise, the LL instruction is not issued.

As used herein, an instruction may be speculative if its controldependencies are not yet resolved. That is, if preceding instructionsmay cause the instruction not to be executed and its results committed,the instruction is speculative. Preceding branch instructions may bemispredicted, meaning that the instruction is not in the correctexecution path and thus is not executed. A preceding instruction mayexperience an exception, thus causing the instruction to be canceled andexecution to proceed to an exception vector. A preceding instruction maybe replayed, thus causing the instruction to be canceled and reexecutedsubsequently. For the present embodiment, an instruction may bespeculative if any preceding instructions have not yet reached thegraduation stage of the pipeline.

Turning now to FIG. 5, a flowchart is shown illustrating operation ofone embodiment of the LL control circuit 56. Other embodiments arepossible and contemplated. While the blocks shown in FIG. 5 areillustrated in a particular order for ease of understanding, otherorders may be used. The embodiment illustrated in FIG. 5 may representthe operation of circuitry in the LL control circuit 56. Thus, blocksmay represent parallel operation of the circuitry rather than anyparticular order. Furthermore, some blocks may be independent of eachother and thus may represent independent circuitry that operates inparallel. For example, the decision blocks 80, 82, 84, and 86 (andblocks on the yes legs thereof) may each represent independent circuitrywhich operates in parallel.

If the LL control circuit 56 receives an LL instruction (decision block80), the LL control circuit 56 updates the reservation register 58A-58Dcorresponding to the bank accessed by the LL instruction. Specifically,the LL control circuit 56 may store the PA of the LL instruction in thereservation register (block 88) and sets the LL bit in that register(block 90).

If the LL control circuit 56 receives a graduated SC instruction (an SCinstruction which has passed the graduation stage) (decision block 82),the LL control circuit compares the address of the SC instruction to theaddress in the reservation registers 58A-58D and checks thecorresponding LL bit (decision block 92). If the addresses match and theLL bit is set, the LL control circuit 56 reports a successful SC via theSC_stat indication (block 94) and clears the LL bit in the register forwhich the addresses matched (block 96). If the addresses do not match orthe LL bit is clear, the LL control circuit 56 reports an unsuccessfulSC via the SC_stat indication (block 98).

If the LL control circuit 56 receives an asserted Clr_LL indication fromthe issue control circuit 42 (decision block 84), the LL control circuit56 clears all the LL bits in the reservation registers 58A-58D (block100). Finally, if a snoop hit is detected (the snoop address matches areservation address in one of the reservation registers 58A-58D and thetype indicates that an update may be performed by another master) or anevict address matches a reservation address (decision block 86), the LLcontrol circuit 56 clears the LL bit in the corresponding reservationregister 58A-58D (block 102).

Turning next to FIG. 6, a block diagram of a carrier medium 300including one or more data structures representative of the processor 10is shown. Generally speaking, a carrier medium may include storage mediasuch as magnetic or optical media, e.g., disk or CD-ROM, volatile ornon-volatile memory media such as RAM (e.g. SDRAM, RDRAM, SRAM, etc.),ROM, etc., as well as transmission media or signals such as electrical,electromagnetic, or digital signals, conveyed via a communication mediumsuch as a network and/or a wireless link.

Generally, the data structure(s) of the processor 10 carried on carriermedium 300 may be read by a program and used, directly or indirectly, tofabricate the hardware comprising the processor 10. For example, thedata structure(s) may include one or more behavioral-level descriptionsor register-transfer level (RTL) descriptions of the hardwarefunctionality in a high level design language (HDL) such as Verilog orVHDL. The description(s) may be read by a synthesis tool which maysynthesize the description to produce one or more netlist(s) comprisinglists of gates from a synthesis library. The netlist(s) comprise a setof gates which also represent the functionality of the hardwarecomprising the processor 10. The netlist(s) may then be placed androuted to produce one or more data set(s) describing geometric shapes tobe applied to masks. The masks may then be used in various semiconductorfabrication steps to produce a semiconductor circuit or circuitscorresponding to the processor 10. Alternatively, the data structure(s)on carrier medium 300 may be the netlist(s) (with or without thesynthesis library) or the data set(s), as desired.

While carrier medium 300 carries a representation of the processor 10,other embodiments may carry a representation of any portion of processor10, as desired, including a fetch/decode/issue unit 14, one or moreload/store units 28A-28B, load/store pipelines 50, issue control circuit42, issue queue 40, LL control circuit 56, reservation registers58A-58D, LL_set circuits 60, etc.

Numerous variations and modifications will become apparent to thoseskilled in the art once the above disclosure is fully appreciated. It isintended that the following claims be interpreted to embrace all suchvariations and modifications.

1-12. (canceled)
 13. A method comprising: determining whether or not atleast one reservation is valid in a processor; responsive to no validreservation, selecting a speculative load-linked instruction for issue,wherein a reservation is established responsive to processing aload-linked instruction, and wherein a load-linked instruction is a loadinstruction that is architecturally defined to establish thereservation, and wherein a valid reservation is indicative that one ormore bytes indicated by the target address of the load-linkedinstruction have not been updated since the reservation was established;and responsive to at least one valid reservation, not selecting thespeculative load-linked instruction for issue.
 14. The method as recitedin claim 13 further comprising not selecting the speculative load-linkedinstruction if a load-linked instruction is in a pipeline of theprocessor, even if the determining indicates no valid reservation. 15.The method as recited in claim 13 wherein the processor includes a firststorage device configured to store a target address of a load-linkedinstruction and a reservation indication, wherein the reservationindication is indicative, in a first state, that a reservation is validfor the target address stored in the storage device and wherein thereservation indication is indicative, in a second state, that thereservation is not valid for the target address stored in the storagedevice, the method further comprising: storing the target address in thefirst storage device responsive to the speculative load-linkedinstruction; and placing the reservation indication in the first stateresponsive to the speculative load-linked instruction.
 16. The method asrecited in claim 15 wherein the first storage device is one of aplurality of storage devices, each configured to store a target addressand a reservation indication, and wherein the processor includes a datacache including a plurality of banks, wherein each of the plurality ofstorage devices is associated with a different one of the plurality ofbanks, wherein the storing is performed to one of the plurality ofstorage devices responsive to which of the plurality of banks isaccessed by the speculative load-linked instruction.
 17. The method asrecited in claim 15 further comprising, in response to the speculativeload-linked instruction not completing execution, placing thereservation indication into the second state. 18-19. (canceled)